home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 November / PCWNOV08.iso / Software / Freeware / NoScript 1.7.7 / noscript-1.7.7-fx+mz+sm.xpi / chrome / noscript.jar / content / noscript / noscript.js < prev    next >
Encoding:
Text File  |  2008-07-14  |  2.2 KB  |  88 lines

  1. var noscriptUtil = {
  2.   chromeBase: "chrome://noscript/content/",
  3.   chromeName: "noscript",
  4.   _service: null, 
  5.   get service() {
  6.     if(this._service) return this._service;
  7.     var s = null;
  8.     for(var attempt=1; attempt<=2;attempt++) {
  9.       try {
  10.        s = Components.classes["@maone.net/noscript-service;1"].getService().wrappedJSObject;
  11.        break;
  12.       } catch(ex) {
  13.         dump(ex.message);
  14.         window.navigator.plugins.refresh();
  15.       }
  16.     }
  17.     if(s != null) {
  18.       s.init();
  19.     }
  20.     return this._service = s;
  21.   }, 
  22.   get prompter() {
  23.     return Components.classes["@mozilla.org/embedcomp/prompt-service;1"
  24.           ].getService(Components.interfaces.nsIPromptService);
  25.   }
  26. ,
  27.   confirm: function(msg, persistPref, title) {
  28.     const ns = this.service; 
  29.     var alwaysAsk = { value: ns.getPref(persistPref, true) };
  30.      if((!alwaysAsk.value) || 
  31.         noscriptUtil.prompter.confirmCheck(window, title || "NoScript",
  32.           msg,
  33.           noscriptUtil.getString("alwaysAsk"), alwaysAsk)
  34.      ) {
  35.       ns.setPref(persistPref, alwaysAsk.value);
  36.       return true;
  37.     }
  38.     return false;
  39.   },
  40.  
  41.   getString: function(key, parms) {
  42.     return this._service.getString(key, parms);
  43.   }
  44. ,
  45.   openOptionsDialog: function(params) {
  46.     window.openDialog(
  47.         this.chromeBase + this.chromeName + "Options.xul", 
  48.         this.chromeName + "Options",
  49.         "chrome, dialog, centerscreen, alwaysRaised",
  50.         params);  
  51.   },
  52.   
  53.   
  54.   openXssOptions: function() {
  55.     this.openOptionsDialog({tabselIndexes: [5, 2]});
  56.   },
  57.   openJarOptions: function() {
  58.     this.openOptionsDialog({tabselIndexes: [5, 3]});
  59.   }
  60. ,
  61.   openAboutDialog: function(params) {
  62.     window.open(
  63.       this.chromeBase + "about.xul", 
  64.       this.chromeName + "About",
  65.       "chrome,dialog,centerscreen");
  66.   }
  67. ,
  68.   openConsole: function() {
  69.     toJavaScriptConsole();
  70.   },
  71.   
  72.   openFaq: function(which) {
  73.     this.browse("http://noscript.net/faq#" + which);
  74.   },
  75.   
  76.   
  77.   browse: function(url, features) {
  78.     var w = this.service.domUtils.mostRecentBrowserWindow;
  79.     if(w && !w.closed) {
  80.       var browser = w.getBrowser();
  81.       browser.selectedTab = browser.addTab(url, null);
  82.     } else {
  83.       window.open(url, "_blank", features || null)
  84.     }
  85.   }
  86.   
  87. };
  88.